package com.supply.pojo;

import lombok.Data;

/**
 * 请求结果封装类
 */
@Data
public class ResultBean {
    private Integer code;
    private String message;
    private Object data;

    public static ResultBean success(){
        ResultBean rs = new ResultBean();
        rs.code = 200;
        rs.message = "操作成功";
        return rs;
    }
    public static ResultBean success(Object object){
        ResultBean rs = new ResultBean();
        rs.code = 200;
        rs.message = "操作成功";
        rs.data = object;
        return rs;
    }
    public static ResultBean info(String message){
        ResultBean rs = new ResultBean();
        rs.code = 300;
        rs.message = message;
        return rs;
    }
    public static ResultBean noPermission(){
        ResultBean rs = new ResultBean();
        rs.code = 100;
        rs.message = "你无权执行此操作";
        return rs;
    }
    public static ResultBean error(){
        ResultBean rs = new ResultBean();
        rs.code = 500;
        rs.message = "服务器异常";
        return rs;
    }
    public static ResultBean error(String msg){
        ResultBean rs = new ResultBean();
        rs.code = 500;
        rs.message = msg;
        return rs;
    }
}
